/***
 *                 .-~~~~~~~~~-._       _.-~~~~~~~~~-.
 *             __.'              ~.   .~              `.__
 *           .'//                 \./                   \\`.
 *         .'//                     |                     \\`.
 *       .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-. \\`.
 *     .'//.-"                 `-.  |  .-'                 "-.\\`.
 *   .'//______.============-..   \ | /   ..-============.______\\`.
 * .'______________________________\|/______________________________`.
 * When I wrote this, only God and I understood what I was doing
 *                      Now, God only knows
 * ALL IS WELL!!!
 * @author Zero~guang
 * @create 2021-07-15 20:42
 */
package com.qianfeng.strategy.filter.impl;

import com.qianfeng.smsplatform.common.constants.CacheConstants;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import com.qianfeng.strategy.feign.CacheService;
import com.qianfeng.strategy.filter.FilterChain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

//@Component
public class BlackFilterWithRedisSet implements FilterChain {
    private CacheService cacheService;

    @Autowired
    public void setCacheService(CacheService cacheService) {
        this.cacheService = cacheService;
    }

    @Override
    public boolean dealSms(Standard_Submit standard_submit) {
        //当前的过滤器进行的操作是判断手机号是不是黑名单
        //黑名单我们通过set的方式保存在了redis中
        //要判断的方式非常简单.直接判单当前的手机号在不在set中就可以
        String destMobile = standard_submit.getDestMobile();
        Boolean member = cacheService.isMember(CacheConstants.CACHE_BLACK_KEY, destMobile);
        if (member){
            System.err.println(destMobile + "------->在黑名单中set");
        }else {
            System.err.println(destMobile + "========>不在黑名单中set");
            return true;
        }
        return false;
    }
}
